package org.example.system.controller;

import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.extern.slf4j.Slf4j;
import org.example.system.entity.DealLog;
import org.example.system.service.DealLogService;
import org.example.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 交易记录控制层
 */
@RestController
@Slf4j
@RequestMapping("/admin/deallog")
public class DealLogController {
    @Autowired
    private DealLogService dealLogService;

    /**
     * 按条件分页查询
     * @param operateLog
     * @return
     */
    @GetMapping("/list")
    public R list(DealLog operateLog){
        IPage<DealLog> page = dealLogService.selectPage(operateLog);
        log.info("------------ DealLogController | list | selectPage | return : {} ", JSON.toJSONString(page));
        return R.ok(page);
    }

    /**
     * 删除
     * @param ids
     * @return
     */
    @DeleteMapping( "/{ids}")
    public R delete(@PathVariable("ids") Long[] ids){
        log.info("--------- DealLogController | delete | input : {}", JSON.toJSON(ids));
        int row = dealLogService.deleteBatch(ids);
        if(row <= 0){
            return  R.fail("删除失败");
        }
        return R.ok("删除成功");
    }
}
